<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <!-- <button>1.操作元素文本内容</button>
    <div>
        <p>文本内容</p>
    </div>

    <script>
        // 获取元素
        var ele = document.querySelector('div')
        var btn = document.querySelector('button')
        // 获取元素的文本内容
        console.log(ele.innerText)

        // 给按钮绑定点击事件
        btn.onclick = function(){
            ele.innerText = '新内容'
        }
    </script> -->



    <button>2.操作元素超文本内容</button>
    <div>
        <p>文本内容</p>
    </div>

    <script>
        // 获取元素
        var ele = document.querySelector('div')
        var btn = document.querySelector('button')
        // 获取元素的文本内容
        console.log(ele.innerHTML)

        // 给按钮绑定点击事件
        btn.onclick = function(){
            ele.innerHTML = '新内容'
        }
    </script>
</body>
</html>